<view>
    <view class="container">
        <view class="item" wx:for="{{balanceList}}"  wx:key="{{item.createTime}}">
            <view class="top">
                <text>{{item.note}}</text>
                <text >
                    <text class="{{item.dir==1 ?'.red':''}}">{{item.dir==0?"+":"-"}}</text>
                    <text class="{{item.dir==1 ?'.red':''}}">{{item.balance+'元'}}</text>
                </text>
            </view>
            <view class="bottom">
                <text>余额：{{item.endBalance}}元</text>
                <text> {{util.formatDate(item.createTime)}}</text>
            </view>
        </view>
        
        <view class="load">
            <image wx:if="{{!isLast}}" class="loading" src="{{imageUrl}}/loading.png"></image>
            <view class="text">{{isLast?"您没有更多余额明细了":"数据加载中..."}}</view>
        </view>
    </view>
</view>
<wxs module="util"> 
    var formatNum=function(n){ 
        return Number(n) 
    } 
    var formatNumber =function(n){
        n = n.toString()
        return n[1] ? n : '0' + n
      }
    var formatDate=function(millisecond){
        var  date=getDate(millisecond),
         year = date.getFullYear(),
         month = date.getMonth() + 1,
         day = date.getDate(),
         hour = date.getHours(),
         minute = date.getMinutes(),
         second = date.getSeconds();
        return [year, month, day].map(formatNumber).join('-') + '   '+' ' + [hour, minute].map(formatNumber).join(':')
    } 
    module.exports = { 
        formatNum : formatNum, 
        formatDate:formatDate
    }
</wxs>